package com.newblog.dao;

public abstract class BlogFactory {
	private static  Object initLock = new Object();
	
	private static final String DEFAULTFACTORY = "con.newblog.dao.MysqlBlogFactory";
	
	private static BlogFactory factory;
	
	/**
	 * 
	 * @return BlogFactory
	 */
	public static synchronized BlogFactory getInstance(){
		if (factory == null){
			try{
				Class c = Class.forName(DEFAULTFACTORY);
				factory = (BlogFactory)c.newInstance();
			}
			catch(ClassNotFoundException e){
				e.printStackTrace();
			}
			catch(IllegalAccessException e){
				e.printStackTrace();
			}
			catch(InstantiationException e){
				e.printStackTrace();
			}
		}
		return factory;
		
	}
	
	public abstract CategoryDAO createCategoryDao();
	
	public abstract PostDAO     createPostDao();
	
	public abstract TagDAO      createTagDao();
	
	public abstract UserDAO     createUserDao();
	
	public abstract CommentDAO  createCommentDao();

}
